package com.zhaohanlin.start;

import org.junit.Test;

import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author zhaohanlin
 */

public class TestFour {
    @Test
    public void four() {
        Stack<Integer> stack = new Stack<>();
        stack.push(100);
        stack.push(200);
        stack.push(300);
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.peek());
        System.out.println(stack);
    }

    @Test
    public void four1() {
        Queue<Integer> queue = new LinkedBlockingDeque<>();
        queue.add(105);
        queue.add(205);
        queue.add(305);
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.peek());
        System.out.println(queue);
    }

    //题目： 求数组：{1, 3, 5, 7, 9, 2, 4, 6, 8, 0}，的最小值，最大值和平均值。
    @Test
    public void test1() {
        int[] arrA = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0};
        int max = arrA[0], min = arrA[0], length = arrA.length;
        double ave = 0;
        for (int i = 0; i < length; i++) {
            if (max < arrA[i]) {
                max = arrA[i];
            }
            if (min > arrA[i]) {
                min = arrA[i];
            }
            ave += arrA[i];
        }
        System.out.println("最小值为:" + min);
        System.out.println("最大值为:" + max);
        System.out.println("平均值为:" + ave / length);
    }

    @Test
    public void add() {
        Queue<Integer> queue = new LinkedBlockingQueue<>();
        for (int i = 0; i < 10; i++) {
            queue.add(i + 1);
        }
        while (queue.size() != 1) {
            queue.add(queue.poll());
            queue.add(queue.poll());
            queue.poll();
            System.out.println(queue);
        }

    }
@Test
    public void add12() {
        int a=0;
        for (int i = 1; i <= 8; i++) {
            Scanner scanner =new Scanner(System.in);
            a++;


            }
        }

    }





